package com.stations.controller;

import com.stations.common.aop.annotation.Log;
import com.stations.common.aop.enums.BusinessType;
import com.stations.common.constant.ControllerConstant;
import com.stations.common.web.base.BaseController;
import com.stations.common.web.domain.response.module.ResultTree;
import com.stations.domain.SysRegion;
import com.stations.service.SysRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Describe: 区域获取
 * Author: Ljy
 * CreateTime: 2019/10/23
 */
@RestController
@Api(tags = {"区域获取"})
@RequestMapping(ControllerConstant.API_SYSTEM_PREFIX + "region")
public class SysRegionController extends BaseController {

    @Resource
    SysRegionService sysRegionService;

    /**
     * Describe: 查询区域树
     * Param ModelAndView
     * Return 区域树数据
     */
    @GetMapping("data")
    @ApiOperation(value = "获取区域列表数据")
    @PreAuthorize("hasPermission('/system/region/data','sys:region:data')")
    @Log(title = "查询区域树", describe = "查询区域树", type = BusinessType.QUERY)
    public ResultTree data(SysRegion sysRegion) {
        List<SysRegion> list = sysRegionService.list(sysRegion);
        return dataTree(list);
    }

}
